<?php
include_once('app/itemLib.php');
//RENAME CATEGORY
if(post('rename') != 'null')
{
	$tableName = 'inv_category';
	
	$fields = array();
	$fields[0] = 'catName';
	
	$values = array();
	$values[0] = post('catName');
	
	$whereClause = 'catID="'.post('rename').'"';
	
	$data = SQLUpdate($tableName, $whereClause, $fields, $values);
}
if(post('delete') != 'null')
{
	$data = SQLDelete ('inv_category', 'catID="'.post('delete').'"');
	
	$tableName = 'inv_item';
	
	$fields = array();
	$fields[0] = 'active';
	
	$values = array();
	$values[0] = '1';
	
	$whereClause = 'category="'.post('delete').'"';
	
	$data = SQLUpdate($tableName, $whereClause, $fields, $values);
}
$categLists = recoverCategories();
$jsCategories = '';
for ($i=0; $i<sizeOf($categLists['catName']); $i++)
{
	$jsCategories .= 'availCategories['.$i.'] = \''.$categLists['catName'][$i].'\';
	';
}
$jsCategories .= 'availCategories['.sizeOf($categLists['catName']).'] = \'Deleted\';
	';
	
$extraJS = '
	var availCategories = new Array;
	'.$jsCategories.'
	';

$dynCSS = '';
$dynJS = $extraJS;
?>